package com.sunlee.app.api.controller;

import com.sunlee.common.core.entity.Result;
import com.sunlee.common.service.dto.AboutConfigDTO;
import com.sunlee.common.service.dto.AboutConfigListDTO;
import com.sunlee.common.service.service.AboutConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 关于页面配置表
 *
 * @author sunlee
 */
@RestController
@RequestMapping("aboutConfig")
public class AboutConfigController {

    @Autowired
    private AboutConfigService aboutConfigService;


    @GetMapping(value = {"/list/{type}", "/list"})
    public Result<List<AboutConfigListDTO>> listByType(@PathVariable(required = false) String type) {
        if (StringUtils.isBlank(type)) {
            type = "0";
        }
        return Result.ok(aboutConfigService.getListByType(type));
    }

    @GetMapping("{id}")
    public Result<AboutConfigDTO> get(@PathVariable("id") Long id) {
        return Result.ok(aboutConfigService.getOwn(id));
    }
}